package com.sample.action;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sample.action.form.ZhaoshengForm;

import com.sample.javabean.Zhaosheng;
import com.sample.util.Pager;

     /**
     * @author梁桂花
     *
     * 2018-10-24
     */
           public class ZhaoshengAction extends BaseAction {
    	 
      
    	   private final static Log log=LogFactory.getLog(ZhaoshengAction.class);
    	 	private Pager<Zhaosheng> pageList;
    	 	private String sno;
    	 	private Integer id;
    	 	private  Zhaosheng  zhaosheng=new Zhaosheng();
    	 	private  ZhaoshengForm zhaoshengForm=new ZhaoshengForm();
    	 	
    	 	
    	 	/**
    	 	 * 幼儿信息录入界面
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String inputZhaosheng()throws Exception{
    	 		
    	 		return "inputZhaosheng";
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String save()throws Exception{
    	 		try{
    	 			log.info("添加招生信息");
    	 			if(zhaoshengForm!=null){
    	 				Zhaosheng zhaosheng =new Zhaosheng();
    	 				 //将persinfoForm中的属性值一一对应persinfo的对应属性
    	 				zhaosheng.setName(zhaoshengForm.getName());
    	 				zhaosheng.setSex(zhaoshengForm.getSex());
    	 				zhaosheng.setSno(zhaoshengForm.getSno());
    	 				zhaosheng.setBirthday(zhaoshengForm.getBirthday());
    	 				zhaosheng.setClassName(zhaoshengForm.getClassName());
    	 				zhaosheng.setAddress(zhaoshengForm.getAddress());
    	 				zhaosheng.setTel(zhaoshengForm.getTel());
    	 				zhaosheng.setPname(zhaoshengForm.getPname());
    	 				zhaosheng.setCardno(zhaoshengForm.getCardno());
    	 			
    	 				
    	 			   //调用方法
    	 				zhaosheng.add();
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			
    	 		}
    	 		return "inputZhaosheng";
    	 	}
    	 	
    		public String list()throws Exception{
    			Zhaosheng zhaoshengModel =new Zhaosheng();
    	 		pageList =zhaoshengModel.list(page,size,zhaoshengForm);
    	 		return "listZhaosheng";
    	 	}
    	 	public String del()throws Exception{
    	 		try{
    	 			if(zhaoshengForm!=null){
    	 				zhaosheng.setSno(sno);
    	 				zhaosheng.delZhaosheng();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	public String editZhaosheng()throws Exception{
    	 		try{
    	 			zhaosheng.setId(id);
    	 			zhaosheng.load();
    	 			return "editZhaosheng";
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
    	 	/**
    	 	 * 
    	 	 * @return
    	 	 * @throws Exception
    	 	 */
    	 	public String edit()throws Exception{
    	 		try{
    	 			
    	 			if(zhaoshengForm!=null){
    	 					
    	 				
    	 				zhaosheng.setId(zhaoshengForm.getId());
    	 				zhaosheng.setName(zhaoshengForm.getName());
    	 				zhaosheng.setSex(zhaoshengForm.getSex());
    	 				zhaosheng.setSno(zhaoshengForm.getSno());
    	 				zhaosheng.setBirthday(zhaoshengForm.getBirthday());
    	 				zhaosheng.setClassName(zhaoshengForm.getClassName());
    	 				zhaosheng.setAddress(zhaoshengForm.getAddress());
    	 				zhaosheng.setTel(zhaoshengForm.getTel());
    	 				zhaosheng.setPname(zhaoshengForm.getPname());
    	 				zhaosheng.setCardno(zhaoshengForm.getCardno());
    	 				zhaosheng.editZhaosheng();	
    	 			}
    	 			return SUCCESS;
    	 		}catch (Exception e) {
    	 			e.printStackTrace();
    	 			throw e;
    	 		}	
    	 	}
			public Pager<Zhaosheng> getPageList() {
				return pageList;
			}
			public void setPageList(Pager<Zhaosheng> pageList) {
				this.pageList = pageList;
			}
			public String getSno() {
				return sno;
			}
			public void setSno(String sno) {
				this.sno = sno;
			}
			public Zhaosheng getZhaosheng() {
				return zhaosheng;
			}
			public void setZhaosheng(Zhaosheng zhaosheng) {
				this.zhaosheng = zhaosheng;
			}
			public ZhaoshengForm getZhaoshengForm() {
				return zhaoshengForm;
			}
			public void setZhaoshengForm(ZhaoshengForm zhaoshengForm) {
				this.zhaoshengForm = zhaoshengForm;
			}
			public static Log getLog() {
				return log;
			}
			public Integer getId() {
				return id;
			}
			public void setId(Integer id) {
				this.id = id;
			}
			
			

    	
}
